function _Invoke(invokeType, params)
{
    if (invokeType == 'wps')
    {
        _WpsInvoke(params);
    }
    if(invokeType == 'et')
    {
        _EtInvoke(params);
    }
}

// 获取当前模块
function getModulename() {
    return getHttpResponseString("/openagent?agent=149DkjYxMEAP9SXCrx1/PoCdfgTlud56wroxaCcAxcwZbGFi3QwW8YTPKXh9jZPBd&flowsessionid=" + document.all.flowsessionid.value);
}

function editGwDoc(P_WebAdoptobj, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs)
{
    editGwDocV2(strServerAddress,P_WebAdoptobj, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,getModulename(),username,false,true,null,null,null);
}

function editGwDocV2(strServerAddress,P_WebAdoptobj, P_attaunid, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,P_ModuleName,username,P_ShowRevision,P_RedHeadVisible,P_SealData,P_InitRedHeaderUnid,P_Personunid,P_FWZ) {
    if (typeof(P_RedHeadVisible) == 'undefined') P_RedHeadVisible = true;
    //var strServerAddress = "http://" + window.location.host;
    var strServerAddress = strServerAddress;
    //alert(strServerAddress);
    //var strServerAddress = "http://localhost:8078";
		var mbmc="";//模板名称
	if(P_DefaultMb=="行政发文单")
	{
		mbmc="xzfw";
	}
	else if(P_DefaultMb=="党委发文单")
	{
		mbmc="dwfw";
	}
	else if(P_DefaultMb=="通知发文单（专用）")
	{
		mbmc="tzzy";
	}
	else if(P_DefaultMb=="纪委发文单")
	{
		mbmc="jwfw";
	}
	else if(P_DefaultMb=="函发文单")
	{
		mbmc="hfw";
	}
	else if(P_DefaultMb=="纪要发文单（专用）")
	{
		mbmc="jyfwzy";
	}
	else if(P_DefaultMb=="通报发文单(专用)")
	{
		mbmc="tbfwzy";
	}
	else if(P_DefaultMb=="高速公路前期工作情况专报")
	{
		mbmc="gsglgzzb";
	}
	else if(P_DefaultMb=="普通国道前期工作情况专报")
	{
		mbmc="ptgdgzzb";
	}
	else if(P_DefaultMb=="三年消危行动工作情况专报")
	{
		mbmc="snxwgzzb";
	}
	else if(P_DefaultMb=="高速公路建设工作专班简报")
	{
		mbmc="jsgz";
	}
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/word-files/openOfficewithperson?unid=" + P_attaunid+"&wjlx="+mbmc+"&personname="+username;
    //上传正文地址
    var uploadPath = strServerAddress + "/gwfj/word-files/upload/" + P_DocUnid + "/" + P_ModuleName;
    //文件解锁地址
    var unLockPath = strServerAddress + "/gwfj/word-files/unLockOffice/" + P_DocUnid;
    //红头文件地址

    var redHeadsPath = strServerAddress + "/gwmb/open/list?modules="+P_ModuleName+"&personunid="+P_Personunid +"&personname=" +username;
    if(P_FWZ != null)
    {
        redHeadsPath = redHeadsPath + "&fwz=" + P_FWZ; 
    }
    var redHeadBase = strServerAddress + "/attachment/api/openOffice?unid=";
    var username = username;
    //不落地方式，上传失败，还在于wps沟通中
    // _WpsInvoke([{
    //     "OnlineEditDoc": {
    //         "docId": P_DocUnid, // 文档ID
    //         "uploadPath": uploadPath, // 保存文档上传路径
    //         "fileName": downloadPath,
    //         "uploadFieldName": "inputName",
    //         "userName": getCurrentUserFullName(),
    //         "redHeadsPath": redHeadsPath,
    //         "redHeadBase": redHeadBase,
    //         "bkInsertFile": "正文",
    //         "redFileElement": P_Bookmarks,
    //         "buttonGroups": "grpWPSClound,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice", //屏蔽功能按钮
    //         "revisionCtrl":
    //             {
    //                 "bOpenRevision": true,
    //                 "bShowRevision": false
    //             }
    //     }
    // }]);
    
    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "fileName": downloadPath,
            "unLockPath": unLockPath,
            "moduleName": P_ModuleName,
           // "userName": getCurrentUserFullName(),
            "userName": username,
            "redHeadsPath": redHeadsPath,
            "redHeadBase": redHeadBase,
            "bkInsertFile": "正文",
            "uploadFieldName": "file",
            "redFileElement": P_Bookmarks,
            "buttonGroups": "grpWPSClound,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice,btnAcceptAllRevisions,btnRejectAllRevisions" + P_Externs, //屏蔽功能按钮
            "revisionCtrl":
                {
                    "bOpenRevision": true,
                    "bShowRevision": P_ShowRevision ? P_ShowRevision : false
                },
            "redHeadVisible": P_RedHeadVisible,
            "sealData": P_SealData,
            "initRedHeaderUnid": P_InitRedHeaderUnid
        }
    }]);
}

/**
 * 编辑附件
 * @param { String } P_ServerAddress 服务器地址
 * @param {*} P_DocUnid 文档unid 
 * @param {*} P_ModuleName 模块名称
 * @param {*} P_Username 用户名称 
 */
function editGwDocFj(P_ServerAddress, P_DocUnid,P_ModuleName,P_Username) {
    //下载文件地址
    var downloadPath = P_ServerAddress + "/attachment/api/openOffice?unid=" + P_DocUnid;
    //上传文件地址
    var uploadPath = P_ServerAddress + "/attachment/api/upload/" + P_DocUnid + '/fj/' + P_ModuleName;
    console.log("下载正文地址",downloadPath);
    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "fileName": downloadPath,
            "userName": P_Username,
            "bkInsertFile": "附件",
            "uploadFieldName": "file",
            "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice", //屏蔽功能按钮
            "revisionCtrl":
            {
                "bOpenRevision": true,
                "bShowRevision": false
            },
        }
    }]);
}

function editGwDocV3(strServerAddress,P_WebAdoptobj, P_attaunid, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,P_ModuleName,username,P_RedHeadVisible) {
    if (typeof(P_RedHeadVisible) == 'undefined') P_RedHeadVisible = true;
    //var strServerAddress = "http://" + window.location.host;
    var strServerAddress = strServerAddress;
    //alert(strServerAddress);
    //var strServerAddress = "http://localhost:8078";
    //下载正文地址
    var downloadPath = strServerAddress + "/attachment/api/openOffice?unid=" + P_attaunid;
    //上传正文地址
    var uploadPath = strServerAddress + "/attachment/api/upload/" + P_DocUnid + '/fj/' + P_ModuleName;
    //红头文件地址
    var redHeadsPath = strServerAddress + "/gwmb/open/list";
    var redHeadBase = strServerAddress + "/attachment/api/openOffice?unid=";
    var username = username;
    
    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "fileName": downloadPath,
           // "userName": getCurrentUserFullName(),
            "userName": username,
            "redHeadsPath": redHeadsPath,
            "redHeadBase": redHeadBase,
            "bkInsertFile": "附件",
            "uploadFieldName": "file",
            "redFileElement": P_Bookmarks,
            "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice" + P_Externs, //屏蔽功能按钮
            "revisionCtrl":
                {
                    "bOpenRevision": true,
                    "bShowRevision": false
                },
            "redHeadVisible": P_RedHeadVisible
        }
    }]);
}

function editGZDocV2(strServerAddress,P_WebAdoptobj, P_attaunid, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,P_ModuleName,username,P_RedHeadVisible) {
    if (typeof(P_RedHeadVisible) == 'undefined') P_RedHeadVisible = true;
    //var strServerAddress = "http://" + window.location.host;
    var strServerAddress = strServerAddress;
    //alert(strServerAddress);
    //var strServerAddress = "http://localhost:8078";
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/filedata/openOffice?unid=" + P_attaunid;
    //上传正文地址
    var uploadPath = strServerAddress + "/gwfj/filedata/upload/" + P_DocUnid;
    //红头文件地址
    var redHeadsPath = strServerAddress + "/gwmb/open/list";
    var redHeadBase = strServerAddress + "/attachment/api/openOffice?unid=";
    var username = username;
    //不落地方式，上传失败，还在于wps沟通中
    // _WpsInvoke([{
    //     "OnlineEditDoc": {
    //         "docId": P_DocUnid, // 文档ID
    //         "uploadPath": uploadPath, // 保存文档上传路径
    //         "fileName": downloadPath,
    //         "uploadFieldName": "inputName",
    //         "userName": getCurrentUserFullName(),
    //         "redHeadsPath": redHeadsPath,
    //         "redHeadBase": redHeadBase,
    //         "bkInsertFile": "正文",
    //         "redFileElement": P_Bookmarks,
    //         "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice", //屏蔽功能按钮
    //         "revisionCtrl":
    //             {
    //                 "bOpenRevision": true,
    //                 "bShowRevision": false
    //             }
    //     }
    // }]);

    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "fileName": downloadPath,
           // "userName": getCurrentUserFullName(),
            "userName": username,
            "redHeadsPath": redHeadsPath,
            "redHeadBase": redHeadBase,
            "bkInsertFile": "正文",
            "uploadFieldName": "file",
            "redFileElement": P_Bookmarks,
            "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice" + P_Externs, //屏蔽功能按钮
            "revisionCtrl":
                {
                    "bOpenRevision": true,
                    "bShowRevision": false
                },
            "redHeadVisible": P_RedHeadVisible
        }
    }]);
}

function editZBToGZDocV2(strServerAddress,P_WebAdoptobj, P_attaunid, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,P_ModuleName,username,P_RedHeadVisible) {
    if (typeof(P_RedHeadVisible) == 'undefined') P_RedHeadVisible = true;
    //var strServerAddress = "http://" + window.location.host;
    var strServerAddress = strServerAddress;
    //alert(strServerAddress);
    //var strServerAddress = "http://localhost:8078";
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/filedata/openOfficeWithZB?unid=" + P_attaunid;
    //上传正文地址
    var uploadPath = strServerAddress + "/gwfj/filedata/upload/" + P_DocUnid;
    //红头文件地址
    var redHeadsPath = strServerAddress + "/gwmb/open/list";
    var redHeadBase = strServerAddress + "/attachment/api/openOffice?unid=";
    var username = username;
    //不落地方式，上传失败，还在于wps沟通中
    // _WpsInvoke([{
    //     "OnlineEditDoc": {
    //         "docId": P_DocUnid, // 文档ID
    //         "uploadPath": uploadPath, // 保存文档上传路径
    //         "fileName": downloadPath,
    //         "uploadFieldName": "inputName",
    //         "userName": getCurrentUserFullName(),
    //         "redHeadsPath": redHeadsPath,
    //         "redHeadBase": redHeadBase,
    //         "bkInsertFile": "正文",
    //         "redFileElement": P_Bookmarks,
    //         "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice", //屏蔽功能按钮
    //         "revisionCtrl":
    //             {
    //                 "bOpenRevision": true,
    //                 "bShowRevision": false
    //             }
    //     }
    // }]);

    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "fileName": downloadPath,
           // "userName": getCurrentUserFullName(),
            "userName": username,
            "redHeadsPath": redHeadsPath,
            "redHeadBase": redHeadBase,
            "bkInsertFile": "正文",
            "uploadFieldName": "file",
            "redFileElement": P_Bookmarks,
            "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice" + P_Externs, //屏蔽功能按钮
            "revisionCtrl":
                {
                    "bOpenRevision": true,
                    "bShowRevision": false
                },
            "redHeadVisible": P_RedHeadVisible
        }
    }]);
}

function editGWToGZDocV2(strServerAddress,P_WebAdoptobj, P_attaunid, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,P_ModuleName,username,P_RedHeadVisible,P_SealData) {
    if (typeof(P_RedHeadVisible) == 'undefined') P_RedHeadVisible = true;
    //var strServerAddress = "http://" + window.location.host;
    var strServerAddress = strServerAddress;
    //alert(strServerAddress);
    //var strServerAddress = "http://localhost:8078";
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/word-files/openOffice?unid=" + P_attaunid;
    //上传正文地址
    var uploadPath = strServerAddress + "/gwfj/filedata/upload/" + P_DocUnid;
    //文件解锁地址
    var unLockPath = strServerAddress + "/gwfj/word-files/unLockOffice/" + P_DocUnid;
    //红头文件地址
    var redHeadsPath = strServerAddress + "/gwmb/open/list";
    var redHeadBase = strServerAddress + "/attachment/api/openOffice?unid=";
    var username = username;
    //不落地方式，上传失败，还在于wps沟通中
    // _WpsInvoke([{
    //     "OnlineEditDoc": {
    //         "docId": P_DocUnid, // 文档ID
    //         "uploadPath": uploadPath, // 保存文档上传路径
    //         "fileName": downloadPath,
    //         "uploadFieldName": "inputName",
    //         "userName": getCurrentUserFullName(),
    //         "redHeadsPath": redHeadsPath,
    //         "redHeadBase": redHeadBase,
    //         "bkInsertFile": "正文",
    //         "redFileElement": P_Bookmarks,
    //         "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice", //屏蔽功能按钮
    //         "revisionCtrl":
    //             {
    //                 "bOpenRevision": true,
    //                 "bShowRevision": false
    //             }
    //     }
    // }]);

    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "unLockPath": unLockPath,
            "fileName": downloadPath,
           // "userName": getCurrentUserFullName(),
            "userName": username,
            "redHeadsPath": redHeadsPath,
            "redHeadBase": redHeadBase,
            "bkInsertFile": "正文",
            "uploadFieldName": "file",
            "redFileElement": P_Bookmarks,
            "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice" + P_Externs, //屏蔽功能按钮
            "revisionCtrl":
                {
                    "bOpenRevision": true,
                    "bShowRevision": false
                },
            "redHeadVisible": P_RedHeadVisible,
            "sealData": P_SealData
        }
    }]);
}

function editZhiBanDocV2(strServerAddress,P_WebAdoptobj, P_attaunid, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,P_ModuleName,username,P_RedHeadVisible) {
    if (typeof(P_RedHeadVisible) == 'undefined') P_RedHeadVisible = true;
    //var strServerAddress = "http://" + window.location.host;
    var strServerAddress = strServerAddress;
    //alert(strServerAddress);
    //var strServerAddress = "http://localhost:8078";
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/filedata/openOfficeWithZB?unid=" + P_attaunid;
    //上传正文地址
    var uploadPath = strServerAddress + "/gwfj/filedata/uploadWithZB/" + P_DocUnid;
    //文件解锁地址
    var unLockPath = strServerAddress + "/gwfj/word-files/unLockOffice/" + P_DocUnid;
    //红头文件地址
    var redHeadsPath = strServerAddress + "/gwmb/open/list";
    var redHeadBase = strServerAddress + "/attachment/api/openOffice?unid=";
    var username = username;
    //不落地方式，上传失败，还在于wps沟通中
    // _WpsInvoke([{
    //     "OnlineEditDoc": {
    //         "docId": P_DocUnid, // 文档ID
    //         "uploadPath": uploadPath, // 保存文档上传路径
    //         "fileName": downloadPath,
    //         "uploadFieldName": "inputName",
    //         "userName": getCurrentUserFullName(),
    //         "redHeadsPath": redHeadsPath,
    //         "redHeadBase": redHeadBase,
    //         "bkInsertFile": "正文",
    //         "redFileElement": P_Bookmarks,
    //         "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice", //屏蔽功能按钮
    //         "revisionCtrl":
    //             {
    //                 "bOpenRevision": true,
    //                 "bShowRevision": false
    //             }
    //     }
    // }]);

    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "fileName": downloadPath,
            "unLockPath": unLockPath,
           // "userName": getCurrentUserFullName(),
            "userName": username,
            "redHeadsPath": redHeadsPath,
            "redHeadBase": redHeadBase,
            "bkInsertFile": "正文",
            "uploadFieldName": "file",
            "redFileElement": P_Bookmarks,
            "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice" + P_Externs, //屏蔽功能按钮
            "revisionCtrl":
                {
                    "bOpenRevision": true,
                    "bShowRevision": false
                },
            "redHeadVisible": P_RedHeadVisible
        }
    }]);
}

function editGwToZhiBanDocV2(strServerAddress,P_WebAdoptobj, P_attaunid, P_DocUnid, P_Powers, P_DefaultMb, P_Bookmarks, P_Externs,P_ModuleName,username,P_RedHeadVisible) {
    if (typeof(P_RedHeadVisible) == 'undefined') P_RedHeadVisible = true;
    //var strServerAddress = "http://" + window.location.host;
    var strServerAddress = strServerAddress;
    //alert(strServerAddress);
    //var strServerAddress = "http://localhost:8078";
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/word-files/openOffice?unid=" + P_attaunid;
    //上传正文地址
    var uploadPath = strServerAddress + "/gwfj/filedata/uploadWithZB/" + P_DocUnid;
    //文件解锁地址
    var unLockPath = strServerAddress + "/gwfj/word-files/unLockOffice/" + P_DocUnid;
    //红头文件地址
    var redHeadsPath = strServerAddress + "/gwmb/open/list";
    var redHeadBase = strServerAddress + "/attachment/api/openOffice?unid=";
    var username = username;
    //不落地方式，上传失败，还在于wps沟通中
    // _WpsInvoke([{
    //     "OnlineEditDoc": {
    //         "docId": P_DocUnid, // 文档ID
    //         "uploadPath": uploadPath, // 保存文档上传路径
    //         "fileName": downloadPath,
    //         "uploadFieldName": "inputName",
    //         "userName": getCurrentUserFullName(),
    //         "redHeadsPath": redHeadsPath,
    //         "redHeadBase": redHeadBase,
    //         "bkInsertFile": "正文",
    //         "redFileElement": P_Bookmarks,
    //         "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice", //屏蔽功能按钮
    //         "revisionCtrl":
    //             {
    //                 "bOpenRevision": true,
    //                 "bShowRevision": false
    //             }
    //     }
    // }]);

    //落地方式打开
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "uploadPath": uploadPath, // 保存文档上传路径
            "fileName": downloadPath,
            "unLockPath": unLockPath,
           // "userName": getCurrentUserFullName(),
            "userName": username,
            "redHeadsPath": redHeadsPath,
            "redHeadBase": redHeadBase,
            "bkInsertFile": "正文",
            "uploadFieldName": "file",
            "redFileElement": P_Bookmarks,
            "buttonGroups": "grpWPSClound,btnSaveAsFile,btnChangeToPDF,btnChangeToUOT,btnChangeToOFD,boxWPSWorkEx,btnImportDoc,btnInsertSeal,btnUploadOABackup,btnInsertBookmark,btnImportTemplate,lblDocLandMode,grpFreqUsed,grpNotice" + P_Externs, //屏蔽功能按钮
            "revisionCtrl":
                {
                    "bOpenRevision": true,
                    "bShowRevision": false
                },
                "redHeadVisible": P_RedHeadVisible
        }
    }]);
}

function viewDocument(strServerAddress,P_DocUnid, P_Externs) {
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/word-files/openOffice?unid=" + P_DocUnid;
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "fileName": downloadPath,
            "buttonGroups": "grpWPSClound,grpWPSWork,grpOAExtend,grpFreqUsed,grpDocSource,grpNotice,btnAcceptAllRevisions,btnRejectAllRevisions", //屏蔽功能按钮
            "openType": {
                "protectType": 2
            }
        }
    }]);
}

function viewDocumentWithFileData(strServerAddress,P_DocUnid, P_Externs) {
    //下载正文地址
    var downloadPath = strServerAddress + "/gwfj/filedata/openOffice?unid=" + P_DocUnid;
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "fileName": downloadPath,
            "buttonGroups": "WPSWorkExtTab", //屏蔽功能按钮
            "openType": {
                "protectType": 3
            }
        }
    }]);
}

function viewDocumentWithAttachment(strServerAddress,P_DocUnid, P_Externs) {
    //下载正文地址
  
    var downloadPath = strServerAddress + "/attachment/api/openOffice?unid=" + P_DocUnid;
    _WpsInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "fileName": downloadPath,
            "buttonGroups": "WPSWorkExtTab", //屏蔽功能按钮
            "openType": {
                "protectType": 3
            }
        }
    }]);
}


function viewExcelWithAttachment(strServerAddress,P_DocUnid, P_Externs) {
    //下载正文地址
  
    var downloadPath = strServerAddress + "/attachment/api/openOffice?unid=" + P_DocUnid;
    console.log("下载文件地址",downloadPath);//_EtInvoke
    _EtInvoke([{
        "OpenDoc": {
            "docId": P_DocUnid, // 文档ID
            "fileName": downloadPath,
            "buttonGroups": "WPSWorkExtTab", //屏蔽功能按钮
            "openType": {
                "protectType": 3
            }
        }
    }]);
}

function gethwnd(P_WebAdoptobj) {
    var webadoptObj = P_WebAdoptobj;
    if (typeof (webadoptObj) == "undefined") {
        webadoptObj = document.all.DBWord0;
    }
    if (typeof (webadoptObj) != "undefined") {
        return webadoptObj.GetPropertyValue('tlcthwnd', '');
    } else {
        alert("请安装最新改稿控件。");
    }
    return "";
}

var triggerEl = document.getElementById('trigger_protocol_ifrm');

function launchApplication(url, success, fail) {
    console.log(url);
    triggerEl.src = url;
}


//暂时未使用，准备做文档转换使用
function pDoChangeToOtherDocFormatAndUpload(p_Suffix, p_ShowRevision) {
    var l_doc = wps.WpsApplication().ActiveDocument;
    if (!l_doc) {
        return;
    }
    var l_suffix = p_Suffix;
    //获取该文档对应OA参数的上载路径
    var l_uploadPath = GetDocParamsValue(p_Doc, constStrEnum.uploadAppendPath);
    if (l_uploadPath == "" || l_uploadPath == null) {
        l_uploadPath = GetDocParamsValue(p_Doc, constStrEnum.uploadPath);
    }
    var l_FieldName = GetDocParamsValue(p_Doc, constStrEnum.uploadFieldName);
    if (l_FieldName == "") {
        l_FieldName = wps.PluginStorage.getItem(constStrEnum.DefaultUploadFieldName); //默认是'file'
    }

    if (l_uploadPath == "") {
        alert("系统未传入有效上载文件路径！不能继续转换操作。"); //如果OA未传入上载路径，则给予提示
        return;
    }

    // 先把文档输出保存为指定的文件格式，再上传到后台
    wps.PluginStorage.setItem(constStrEnum.OADocUserSave, true); //设置一个临时变量，用于在BeforeSave事件中判断
    if (p_ShowRevision == false) { // 强制关闭痕迹显示
        var l_SourceName = p_Doc.FullName;
        l_NewName = p_Doc.Path + "\\B_" + p_Doc.Name;
        p_Doc.SaveAs2($FileName = l_NewName, $AddToRecentFiles = false);
        p_Doc.SaveAs2($FileName = l_SourceName, $AddToRecentFiles = false);

        //以下以隐藏模式打开另一个文档
        var l_textEncoding = wps.WpsApplication().Options.DefaultTextEncoding; //默认 936
        var l_Doc = wps.WpsApplication().Documents.Open(l_NewName, false, false, false, "", "", false, "", "", 0, l_textEncoding, false);

        l_Doc.TrackRevision = false; //关闭修订模式
        l_Doc.ShowRevision = false; //隐含属性，隐藏修订模式
        l_Doc.AcceptAllRevisions();
        l_Doc.Save();
        handleFileAndUpload(l_suffix, l_Doc, l_uploadPath, l_FieldName);
        l_Doc.Close();
        wps.FileSystem.Remove(l_NewName); //删除临时文档
    } else {
        handleFileAndUpload(l_suffix, p_Doc, l_uploadPath, l_FieldName);
    }

    wps.PluginStorage.setItem(constStrEnum.OADocUserSave, false);

    return;
}